package com.bw.documents.preview

import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.bw.documents.databinding.ActivityPhotoBinding

@Route(path = "/documents/PhotoActivity")
class PhotoActivity : AppCompatActivity() {
    private val v : ActivityPhotoBinding by lazy {
        ActivityPhotoBinding.inflate(LayoutInflater.from(this))
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(v.root)
        v.photoPage.backImg.setOnClickListener { finish() }
        v.photoPage.titleTv.text = "图片预览"
        val path = intent.extras!!.getString("path")
        Glide.with(this).load(path).into(object :CustomTarget<Drawable>(){
            override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
                v.photoImg.setImageDrawable(resource)
            }
            override fun onLoadCleared(placeholder: Drawable?) {
            }
        })

    }

}